:-load_library('alice.tuprolog.lib.DCGLibrary').

word-->est.
word-->people.
word-->captal.
word-->auxiliary.
word-->er.
word-->than.
word-->who.
%%
%%
people-->[mary].
people-->[john].
people-->[charles].
people-->[lance].
people-->[cherry].
%%
auxiliary -->[does].
auxiliary -->[is].

%%
est-->captal,est.
%%
est-->[yongest].
est-->[oldest].
%%
captal-->[the].
captal-->[a].
%%
v-->[is].

%%
er-->[older].
er-->[younger].

%%
than-->[than].

%%
who-->[who].

%rule%
oldest(mary).
youngest(john).

older_rule(mary, charles). 
older_rule(charles, lance).
older_rule(lance, cherry).
older_rule(cherry, john).
older(T1,T2) :- older_rule(T1,T2). 
older(T1,T2) :- older_rule(X,T2), older(T1,X). 
younger(X,Y):-older(Y,X).

%%
normal_question -->auxiliary,people,est.
sentence-->normal_question.
normal_sentence-->people,v,est.
sentence-->normal_sentence.
compare_question-->auxiliary,people,er,than,people.
compare_sentence-->people,v,er,than,people.
sentence-->compare_question.
sentence-->compare_sentence.
who_question-->who,v,er,than,people.
sentence-->who_question.